package org.bigdata.framework.core.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;



import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;


public class FileUtils {
	/**
	 * Excel文件类
	 */
	public static class Execl {
		/**
		 * excel2003驱动
		 * @param inPath
		 * @return
		 * @throws FileNotFoundException
		 */
		public static HSSFWorkbook getHSSFWork(String inPath) throws FileNotFoundException{
			InputStream is = new FileInputStream(inPath);
			HSSFWorkbook wb = null;
			POIFSFileSystem fs = null;
			try {
				fs = new POIFSFileSystem(is);
				wb = new HSSFWorkbook(fs);
			} catch (IOException e) {
				e.printStackTrace();
			}
			return wb;
		}
		/**
		 * excel2007驱动
		 * @param inPath
		 * @return
		 * @throws FileNotFoundException
		 */
		public static XSSFWorkbook getXSSFWork(String inPath) throws FileNotFoundException{
			InputStream is = new FileInputStream(inPath);
			XSSFWorkbook wb = null;
			try {
				wb = new XSSFWorkbook(is);
			} catch (IOException e) {
				e.printStackTrace();
			}
			return wb;
		}
		/**
		 * 获取excel2003--sheetName
		 * @param inPath
		 * @return
		 * @throws Exception
		 */
		public static String[] getExcelSheetName(HSSFWorkbook wb) throws Exception{
			int numberOfSheets = wb.getNumberOfSheets();
			String []sheetsName=new String[numberOfSheets];
			for (int i = 0; i < numberOfSheets; i++) {
				HSSFSheet sheet = wb.getSheetAt(i);
				sheetsName[i] = sheet.getSheetName();
			}
			return sheetsName;
		}
		/**
		 * 获取excel2007--sheetName
		 * @param inPath
		 * @return
		 * @throws Exception
		 */
		public static String[] getExcelSheetName(XSSFWorkbook wb) throws Exception{
			int numberOfSheets = wb.getNumberOfSheets();
			String []sheetsName=new String[numberOfSheets];
			for (int i = 0; i < numberOfSheets; i++) {
				XSSFSheet sheet = wb.getSheetAt(i);
				sheetsName[i] = sheet.getSheetName();
			}
			return sheetsName;
		}
		/**
		 * 获取excel2003列名称
		 * @param inPath
		 * @param sheetName
		 * @return
		 * @throws Exception
		 */
		public static String[] getColumnName(HSSFWorkbook wb,String sheetName) throws Exception{
			HSSFSheet sheet = wb.getSheet(sheetName);
			HSSFRow columnName = sheet.getRow(0);
			if(columnName==null){
				return new String[0];
			}
			int rowNum = columnName.getLastCellNum();
			String []columnNames=new String[rowNum];
			for (int i = 0; i < rowNum; i++) {
				columnNames[i]=columnName.getCell(i).getStringCellValue();
			}
			return columnNames;
		}
		/**
		 * 获取excel2007列名称
		 * @param inPath
		 * @param sheetName
		 * @return
		 * @throws Exception
		 */
		public static String[] getColumnName(XSSFWorkbook wb,String sheetName) throws Exception{
			XSSFSheet sheet = wb.getSheet(sheetName);
			XSSFRow columnName = sheet.getRow(0);
			if(columnName == null){
				return new String[0];
			}
			int rowNum = columnName.getLastCellNum();
			String []columnNames=new String[rowNum];
			for (int i = 0; i < rowNum; i++) {
				columnNames[i]=columnName.getCell(i).getStringCellValue();
			}
			return columnNames;
		}
		/**
		 * Excel2003获取行数
		 * @param wb
		 * @param sheetName
		 * @return
		 */
		public static int getRowNum(HSSFWorkbook wb,String sheetName){
			HSSFSheet sheet = wb.getSheet(sheetName);
			return sheet.getLastRowNum();
		}
		/**
		 * Excel2007获取行数
		 * @param wb
		 * @param sheetName
		 * @return
		 */
		public static int getRowNum(XSSFWorkbook wb,String sheetName){
			XSSFSheet sheet = wb.getSheet(sheetName);
			return sheet.getLastRowNum();
		}
		/**
		 * Excel2003获取列数
		 * @param wb
		 * @param sheetName
		 * @return
		 */
		public static int getColumnNum(HSSFWorkbook wb,String sheetName){
			HSSFSheet sheet = wb.getSheet(sheetName);
			HSSFRow row = sheet.getRow(0);
			if(row==null){
				return 0;
			}
			return row.getPhysicalNumberOfCells();
		}
		/**
		 * Excel2007获取行数
		 * @param wb
		 * @param sheetName
		 * @return
		 */
		public static int getColumnNum(XSSFWorkbook wb,String sheetName){
			XSSFSheet sheet = wb.getSheet(sheetName);
			XSSFRow row = sheet.getRow(0);
			if(row  == null ){
				return 0;
			}
			return row.getPhysicalNumberOfCells();
		}
		/**
		 * Excel2003类型转换
		 * @param cell
		 * @return
		 */
		public static String getCellFormatValue(HSSFCell cell) {
			String cellvalue = "";
			if (cell != null) {
				switch (cell.getCellType()) {// 判断当前Cell的Type
				case HSSFCell.CELL_TYPE_NUMERIC:// 如果当前Cell的Type为NUMERIC
				case HSSFCell.CELL_TYPE_FORMULA: {// 判断当前的cell是否为Date
					if (HSSFDateUtil.isCellDateFormatted(cell)) {
						// 如果是Date类型则，转化为Data格式
						// 方法1：这样子的data格式是带时分秒的：2011-10-12 0:00:00
						// cellvalue = cell.getDateCellValue().toLocaleString();
						// 方法2：这样子的data格式是不带带时分秒的：2011-10-12
						Date date = cell.getDateCellValue();
						SimpleDateFormat sdf = new SimpleDateFormat(
								"yyyy-MM-dd");
						cellvalue = sdf.format(date);
					} else { // 如果是纯数字
						cellvalue = String.valueOf(cell.getNumericCellValue()); // 取得当前Cell的数值
						if(cellvalue.endsWith(".0")){
							cellvalue=cellvalue.substring(0, cellvalue.length()-2);
						}
					}
					break;
				}
				case XSSFCell.CELL_TYPE_STRING:// 如果当前Cell的Type为String
					cellvalue = cell.getRichStringCellValue().getString();// 取得当前的Cell字符串
					break;
				default: // 默认的Cell值
					cellvalue = " ";
				}
			} else {
				cellvalue = "";
			}
			return cellvalue;
		}
		/**
		 * Excel2007类型转换
		 * @param cell
		 * @return
		 */
		public static String getCellFormatValue(XSSFCell cell) {
			String cellvalue = "";
			if (cell != null) {
				switch (cell.getCellType()) {// 判断当前Cell的Type
				case XSSFCell.CELL_TYPE_NUMERIC:// 如果当前Cell的Type为NUMERIC
				case XSSFCell.CELL_TYPE_FORMULA: {// 判断当前的cell是否为Date
					if (HSSFDateUtil.isCellDateFormatted(cell)) {
						// 如果是Date类型则，转化为Data格式
						// 方法1：这样子的data格式是带时分秒的：2011-10-12 0:00:00
						// cellvalue = cell.getDateCellValue().toLocaleString();
						// 方法2：这样子的data格式是不带带时分秒的：2011-10-12
						Date date = cell.getDateCellValue();
						SimpleDateFormat sdf = new SimpleDateFormat(
								"yyyy-MM-dd");
						cellvalue = sdf.format(date);
					} else { // 如果是纯数字
						cellvalue = String.valueOf(cell.getNumericCellValue()); // 取得当前Cell的数值
						if(cellvalue.endsWith(".0")){
							cellvalue=cellvalue.substring(0, cellvalue.length()-2);
						}
					}
					break;
				}
				case XSSFCell.CELL_TYPE_STRING:// 如果当前Cell的Type为String
					cellvalue = cell.getRichStringCellValue().getString();// 取得当前的Cell字符串
					break;
				default: // 默认的Cell值
					cellvalue = " ";
				}
			} else {
				cellvalue = "";
			}
			return cellvalue;
		}
		/**
		 * 将Excel2003 组装到list->map
		 * @param wb
		 * @param sheetName
		 * @return
		 * @throws Exception
		 */
		public static List<Map<String, Object>> getReadListMap(HSSFWorkbook wb,String sheetName) throws Exception{
			List<Map<String, Object>> listRow = new ArrayList<Map<String, Object>>();
			Map<String, Object> mapRow = new HashMap<String, Object>();
			
			HSSFSheet sheet = wb.getSheet(sheetName);
			String[] columnName = getColumnName(wb, sheetName);
			int rowNum = getRowNum(wb, sheetName);
			int columnNum = getColumnNum(wb, sheetName);
			for (int i = 1; i < rowNum+1; i++) {
				HSSFRow row = sheet.getRow(i);
				mapRow = new HashMap<String, Object>();
				for (int j = 0; j < columnNum; j++) {
					mapRow.put(columnName[j], getCellFormatValue(row.getCell(j)));
				}
				listRow.add(mapRow);
			}
			return listRow;
		}
		/**
		 * 将Excel2007 组装到list->map
		 * @param wb
		 * @param sheetName
		 * @return
		 * @throws Exception
		 */
		public static List<Map<String, Object>> getReadListMap(XSSFWorkbook wb,String sheetName) throws Exception{
			List<Map<String, Object>> listRow = new ArrayList<Map<String, Object>>();
			Map<String, Object> mapRow = new HashMap<String, Object>();
			XSSFSheet sheet = wb.getSheet(sheetName);
			String[] columnName = getColumnName(wb, sheetName);
			int rowNum = getRowNum(wb, sheetName);
			int columnNum = getColumnNum(wb, sheetName);
			for (int i = 1; i < rowNum+1; i++) {
				XSSFRow row = sheet.getRow(i);
				mapRow = new HashMap<String, Object>();
				for (int j = 0; j < columnNum; j++) {
					mapRow.put(columnName[j], getCellFormatValue(row.getCell(j)));
				}
				listRow.add(mapRow);
			}
			return listRow;
		}
		/**
		 * 读取Excel2003
		 * @param inPath
		 * @param sheetName
		 * @return
		 * @throws Exception
		 */
		public static List<Map<String, Object>> readExcel2003(String inPath,String sheetName) throws Exception {
			List<Map<String, Object>> readListMap = new ArrayList<Map<String,Object>>();
			HSSFWorkbook wb = getHSSFWork(inPath);
			int numberOfSheets = wb.getNumberOfSheets();
			if(sheetName == null || sheetName.equals("")){//没有指定sheetName，则全部倒进去
				for (int i = 0; i < numberOfSheets; i++) {
					getReadListMap(wb, wb.getSheetAt(i).getSheetName());
				}
			}else{//指定sheetName，则只导入sheet为sheetName页
				readListMap = getReadListMap(wb, sheetName);
			}
			return readListMap;
		}
		/**
		 * 读取Excel2007
		 * @param inPath
		 * @param sheetName
		 * @return
		 * @throws Exception
		 */
		public static List<Map<String, Object>> readExcel2007(String inPath,String sheetName) throws Exception {
			List<Map<String, Object>> readListMap = new ArrayList<Map<String,Object>>();
			XSSFWorkbook wb = getXSSFWork(inPath);
			int numberOfSheets = wb.getNumberOfSheets();
			if(sheetName == null || sheetName.equals("")){//没有指定sheetName，则全部倒进去
				for (int i = 0; i < numberOfSheets; i++) {
					getReadListMap(wb, wb.getSheetAt(i).getSheetName());
				}
			}else{//指定sheetName，则只导入sheet为sheetName页
				readListMap = getReadListMap(wb, sheetName);
			}
			return readListMap;
		}
		/**
		 * Excel2003和Excel2007 都可以
		 * @param inPath
		 * @param sheetName
		 * @return
		 * @throws Exception
		 */
		public static List<Map<String, Object>> readExcel(String inPath,String sheetName) throws Exception{
			List<Map<String, Object>> readListMap = new ArrayList<Map<String,Object>>();
			if(inPath.endsWith(".xls")){//excel2003
				readListMap = readExcel2003(inPath, sheetName);
			}else if(inPath.endsWith(".xlsx")){//excel2007
				readListMap = readExcel2007(inPath, sheetName);
			}
			return readListMap;
		}
	}
	public static class Txt{
		/**
		 * 读取文件内容------txt中一行为一条数据库数据
		 * @param inPath
		 * @throws Exception 
		 */
		public static List<Map<String,Object>> readTxtFile(String inPath,String rowRegex,String fieldRegex) throws Exception {
			List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
			FileInputStream fis = null;
			InputStreamReader isr = null;
			BufferedReader br = null;
			String str = "";
			fis = new FileInputStream(inPath);
			isr = new InputStreamReader(fis,"utf-8");
			br = new BufferedReader(isr);
			Map<String, String> toMap =null;
			Map<String, Object> map =null;
			while ((str = br.readLine()) != null) {
				if(str.trim().equals("")){
					continue;
				}
				String[] splitRow = splitRow(str, rowRegex);
				map = new HashMap<String, Object>();
				for (int i = 0; i < splitRow.length; i++) {
					 toMap = fieldToMap(splitRow[i], fieldRegex);
					 if(!toMap.isEmpty()){
						 map.putAll(toMap);
					 }
				}
				listMap.add(map);
			}
			close(fis);
			close(isr);
			close(isr);
			return listMap;
		}
		/**
		 * 获取txt文件字段，类型是一行一条数据
		 * @param inPath
		 * @param rowRegex
		 * @param fieldRegex
		 * @return
		 * @throws Exception
		 */
		public static List<Map<String,String>>getFieldName(String inPath,String rowRegex,String fieldRegex) throws Exception{
			List<Map<String,String>> listMap = new ArrayList<Map<String,String>>();
			FileInputStream fis = null;
			InputStreamReader isr = null;
			BufferedReader br = null;
			String str = "";
			fis = new FileInputStream(inPath);
			isr = new InputStreamReader(fis,"utf-8");
			br = new BufferedReader(isr);
			Map<String, String> toMap =null;
			Map<String, String> map =null;
			Map<String, String> map2 =null;
			while ((str = br.readLine()) != null) {
				String[] splitRow = splitRow(str, rowRegex);
				map = new HashMap<String, String>();
				for (int i = 0; i < splitRow.length; i++) {
					 toMap = fieldToMap(splitRow[i], fieldRegex);
					 if(!toMap.isEmpty()){
						 map.putAll(toMap);
					 }
				}
				for (String key : map.keySet()) {
					map2 = new HashMap<String, String>();
					map2.put("fieldName", key);
					listMap.add(map2);
				}
				break;
			}
			close(fis);
			close(isr);
			close(isr);
			return listMap;
		}
		/**
		 * 读取txt字段------txt中多行为一条数据库数据，行空格为一条数据库数据
		 * @param inPath
		 * @throws Exception 
		 */
		public static List<Map<String,String>> getFieldName(String inPath,String fieldRegex) throws Exception {
			List<Map<String,String>> listMap = new ArrayList<Map<String,String>>();
			FileInputStream fis = null;
			InputStreamReader isr = null;
			BufferedReader br = null;
			String str = "";
			fis = new FileInputStream(inPath);
			isr = new InputStreamReader(fis,"utf-8");
			br = new BufferedReader(isr);
			Map<String, String> toMap = null;
			Map<String, String> map2 = null;
			while ((str = br.readLine()) != null) {
				if(str.equals("")){
					break;
				}else{
					toMap=new HashMap<String, String>();
					toMap = fieldToMap(str, fieldRegex);
				}
				for (String key : toMap.keySet()) {
					map2 = new HashMap<String,String>();
					map2.put("fieldName", key);
					listMap.add(map2);
				}
			}
			close(fis);
			close(isr);
			close(isr);
			return listMap;
		}
		/**
		 * 获取txt内容------txt中多行为一条数据库数据，行空格为一条数据库数据
		 * @param inPath
		 * @throws Exception 
		 */
		public static List<Map<String,Object>> readTxtFile(String inPath,String fieldRegex) throws Exception {
			List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
			FileInputStream fis = null;
			InputStreamReader isr = null;
			BufferedReader br = null;
			String str = "";
			fis = new FileInputStream(inPath);
			isr = new InputStreamReader(fis,"utf-8");
			br = new BufferedReader(isr);
			Map<String, String> toMap = null;
			Map<String, Object> map = new HashMap<String,Object>();
			while ((str = br.readLine()) != null) {
				if(str.equals("")){
					if(!map.isEmpty()){
						listMap.add(map);
					}
					map = new HashMap<String,Object>();
				}else{
					toMap = fieldToMap(str, fieldRegex);
					if(!toMap.isEmpty()){
						map.putAll(toMap);
					}
				}
			}
			close(fis);
			close(isr);
			close(isr);
			return listMap;
		}
		/**
		 * 一行一条数据库数据  分割
		 * @param str
		 * @param regex
		 * @return
		 */
		public static String []splitRow(String str,String regex){
			if(str == null || str.equals("")){
				return new String[0];
			}
			return str.split(regex);
		}
		/**
		 * 字段分割
		 * @param str
		 * @param regex
		 * @return
		 */
		public static Map<String, String> fieldToMap(String str,String regex){
			Map<String, String> map = new HashMap<String,String>();
			if(str == null){
				return map;
			}
			String[] split = str.split(regex);
			if(split.length==1 && str.matches("^.*"+regex+".*$")){
				map.put(split[0], "");
				return map;
			}
			StringBuffer sb = new StringBuffer();
			for (int i = 1; i < split.length; i++) {
				if(i==split.length-1){
					sb.append(split[i]);
				}else{
					sb.append(split[i]+regex);
				}
				
			}
			map.put(split[0],sb.toString());
			return map;
		}
		/**
		 * 读取json数据
		 * @param inPath
		 * @return
		 * @throws Exception
		 */
		public static List<Map<String,Object>> readJsonFile(String inPath) throws Exception {
			List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
			StringBuffer sb = readJsonToString(inPath);
			listMap=jsonToMap(sb.toString().trim());
			return listMap;
		}
		/**
		 * 获取json字段
		 * @param inPath
		 * @return
		 * @throws Exception
		 */
		public static List<Map<String,String>> getJsonFieldName(String inPath) throws Exception {
			List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
			List<Map<String,String>> listField = new ArrayList<Map<String,String>>();
			StringBuffer sb = readJsonToString(inPath);
			listMap=jsonToMap(sb.toString().trim());
			Map<String,String> mapf=null;
			if(!listMap.isEmpty()){
				Map<String, Object> map = listMap.get(0);
				for (String key : map.keySet()) {
					mapf=new HashMap<String,String>();
					mapf.put("fieldName", key);
					listField.add(mapf);
				}
			}
			return listField;
		}
		/**
		 * 读取json数据
		 * @param inPath
		 * @return
		 * @throws Exception
		 */
		public static StringBuffer readJsonToString(String inPath) throws Exception {
			FileInputStream fis = null;
			InputStreamReader isr = null;
			BufferedReader br = null;
			String str = "";
			StringBuffer sb = new StringBuffer();
			fis = new FileInputStream(inPath);
			isr = new InputStreamReader(fis,"utf-8");
			br = new BufferedReader(isr);
			while ((str = br.readLine()) != null) {
				if(!str.trim().equals("")){
					sb.append(str);
				}
			}
			close(fis);
			close(isr);
			close(isr);
			return sb;
		}
		/**
		 * 转list<map>
		 * @param str
		 * @return
		 */
		public static List<Map<String,Object>> jsonToMap(String str){
			List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
			Map<String,Object> map = null;
			JSONArray jsonArr = JSONArray.fromObject(str);
			for (int i = 0; i < jsonArr.size(); i++) {
				map = new HashMap<String,Object>();
				JSONObject jsonObj = jsonArr.getJSONObject(i);
				Iterator iterator = jsonObj.keys();
				String key = null;
				String value = null;
				while (iterator.hasNext()) {
					key = (String) iterator.next();
					value = jsonObj.getString(key);
					map.put(key, value);
				}
				listMap.add(map);
			}
			return listMap;
		}
		public static String[] getJsonField(String strt){
			return null;
		}
	}
	/**
	 * xml内部类
	 */
	public static class Xml{
		/**
		 * 加载文件
		 * @param filePath
		 * @return
		 * @throws DocumentException
		 */
		public static  Document getDocument(String filePath) throws DocumentException{
	        File file = new File(filePath);
	        SAXReader saxReader = new SAXReader();
	        Document doc = saxReader.read(file);
	        return doc;
	    }
		/**
		 * 获取第三层标签students->students->id/name/...
		 * <students>
		 * 		<student>
		 * 			<id></id>
		 * 			<name></name>
		 * 		</student>
		 * </students>
		 * @param doc
		 * @return
		 */
		public static String[] getLables(Document doc){
			Element root = doc.getRootElement();
			List<Element> elements = root.elements();
			String []lable = null;
			if(elements.size()!=0){
				Element element = elements.get(0);
				List<Element> elements2 = element.elements();
				lable = new String[elements2.size()];
				for (int i = 0; i < elements2.size(); i++) {
					lable[i]=elements2.get(i).getName();
				}
			}else{
				return new String[0];
			}
	       return lable;
		}
		/**
		 * 获取xml字段
		 * @param doc
		 * @param elementPath
		 * @return
		 */
		public static List<Map<String,String>> getFieldName(Document doc,String elementPath){
			List<Map<String,String>> listMap = new ArrayList<Map<String,String>>();
			Map<String,String> map=null;
			List<Element> selectNodes = doc.selectNodes(elementPath);
			for (Element element : selectNodes) {
				List<Element> elements = element.elements();
				for (Element element2 : elements) {
					map=new HashMap<String, String>();
					map.put("fieldName", element2.getQualifiedName());
					listMap.add(map);
				}
				break;
			}
			return listMap;
		}
		public static List<Map<String,Object>> readXml(String filePath,String elementPath) throws DocumentException{
			Document doc = getDocument(filePath);
			List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
			Map<String,Object> map=null;
			List<Element> selectNodes = doc.selectNodes(elementPath);
			for (Element element : selectNodes) {
				List<Element> elements = element.elements();
				map=new HashMap<String, Object>();
				for (Element element2 : elements) {
					map.put(element2.getQualifiedName(), element2.getText());
				}
				listMap.add(map);
			}
			return listMap;
		}
		
		public static String getNodeText(Document doc,String elementPath){
			Element element = selectSingleNode(doc, elementPath);
			if(element == null){
				return null;
			}
			List<Element> elements = element.elements();
			if(elements.size()==0){
				return  element.getText();
			}else{
				return element.asXML();
			}
		}

		public static Element selectSingleNode(Document doc, String elementPath) {
			Node node = doc.selectSingleNode(elementPath);
			return node == null ? null : (Element) node;
		}

	}
	/**
	 * 关闭
	 * @param auto
	 */
	public static void close(AutoCloseable auto) {
		if (auto != null)
			try {
				auto.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
	}
	public static String trim(String str){
		if(str == null){
			return "";
		}
		if(str.equals("")){
			return str;
		}
		str = str.replaceAll("\\s+", "");
		return str;
	}
	public static void show(List<Map<String, Object>> listMap){
		for (int i = 0; i < listMap.size(); i++) {
			for (String key : listMap.get(i).keySet()) {
				System.out.print(key+":"+listMap.get(i).get(key)+"	");
			}
			System.out.println();
		}
	}
}
